package com.ymatou.iapi.productmanager.service;

import java.util.Arrays;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.ymttest.business.YmatouAutoTestCall;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.MapUtil;

public class ModifyActivityProductSortV3Call extends YmatouAutoTestCall{
	private static String opurl ="api/Product/ModifyActivityProductSortV3";

	
	public ModifyActivityProductSortV3Call() {
		super(EnvSetup.getSystemUrl("productmanager"),opurl,"POST","JSON");
		//super(EnvSetup.getSystemUrl("sellerproduct_iapi"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	
	public JSONObject call(int sellerId,int liveId,List<String> productIdList){
		JSONArray prodList = new JSONArray();
		for(int i=0;i<productIdList.size();i++){
			JSONObject obj = new JSONObject();
			try {
				obj.put("ProductId", productIdList.get(i));
				prodList.put(i, obj);
			} catch (JSONException e) {
				e.printStackTrace();
			}
			
		}
		
		return this.callAndGetReturnData(MapUtil.hashMap("UserId",sellerId,"ActivityId",liveId,"ActivityProductSorts",prodList));
	}
	
	public static void main(String[] args) {
		new ModifyActivityProductSortV3Call().call(3383,3321,Arrays.asList("123","124"));
	}
}
